package util.localization;

import java.io.Serializable;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author Swee Zhi
 */
@ManagedBean
@RequestScoped
public class MenuLocalization implements Serializable {
    // fields for this bean
    private FacesContext ctx = FacesContext.getCurrentInstance();
    private WebLocalization localization;
    private String preferredLocale;
    
    public MenuLocalization() {
        /* LOCALIZATION */
        localization = new WebLocalization();
        preferredLocale = localization.getPreferredLocaleFromSession();
        /* END LOCALIZATION */
    }

    public String getStaffMenuItem(String messageKey)
    {   
        String menuItem = "";

        ResourceBundle staffMenuItemResources = ResourceBundle.getBundle("web.menuitems.StaffMenuItems", ctx.getViewRoot().getLocale());

        // properties file has this key
        if (staffMenuItemResources.containsKey(messageKey)) {
            menuItem = staffMenuItemResources.getString(messageKey);
            }
        // get default value
            else {
           staffMenuItemResources.getString("NO_MENU_ITEM");
            }
            
        return menuItem;
    }
    
    public String getTouristMenuItem(String messageKey)
    {   
        String menuItem = "";
        
        ResourceBundle staffMenuItemResources = ResourceBundle.getBundle("web.menuitems.TouristMenuItems", ctx.getViewRoot().getLocale());

        // properties file has this key
        if (staffMenuItemResources.containsKey(messageKey)) {
            menuItem = staffMenuItemResources.getString(messageKey);
            }
        // get default value
            else {
           staffMenuItemResources.getString("NO_MENU_ITEM");
            }
            
        return menuItem;
    }
    
     public String getStakeholderMenuItem(String messageKey)
            {
        String menuItem = "";

        ResourceBundle staffMenuItemResources = ResourceBundle.getBundle("web.menuitems.StakeholderMenuItems", ctx.getViewRoot().getLocale());

        // properties file has this key
        if (staffMenuItemResources.containsKey(messageKey)) {
            menuItem = staffMenuItemResources.getString(messageKey);
            }
        // get default value
        else {
           staffMenuItemResources.getString("NO_MENU_ITEM");
        }
        
        return menuItem;
    }
    
}
